package cggl;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;

import xtgl.Department;
import xtgl.Role;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
/**
 * 采购计划
 * @author cheng
 * @date 2017.8.21
 * @version 1.0
 */
public class CgjhController extends Controller {
	
	//默认页大小
	static int g_infNumber = 10;

		
	public void index() {
		g_infNumber = 10;
		render("/cggl/cgjh.html");	
	}
	//获取初始页采购计划数据
	public void allCgjh(){		
			Page<Record> cgjh = Db.paginate(getParaToInt("pageNumber", 1),
					g_infNumber, "SELECT "+Cgjh.ALLCOLUMN,"FROM cgjh");
			//setAttr("pN", cgjh.getPageNumber());
			//setAttr("tP", cgjh.getTotalPage());
			renderJson(cgjh);			
	}
	//根据采购计划单查询采购计划子表
	public void findCgjha(){		
		String xqdh = getPara("xqdh");
		List<Cgjha> list = Cgjha.dao.getCgList(xqdh);
		renderJson(list);			
	}
	//按条件查询分页
	public void findCgjhPage(){
		Cgjh cgjh = getModel(Cgjh.class);
		StringBuffer sql = new StringBuffer();
		if (cgjh.getStr("cgjhh")!=null && cgjh.getStr("cgjhh")!="") {
			sql.append("cgjhh = "+"'"+cgjh.getStr("cgjhh")+"'");
		}
		if (cgjh.getStr("xqdh")!=null && cgjh.getStr("xqdh")!="") {
			sql.append("xqdh = "+"'"+cgjh.getStr("xqdh")+"'");
		}	
		if (cgjh.getStr("xqr")!=null && cgjh.getStr("xqr")!="") {
			sql.append("xqr like "+"'"+cgjh.getStr("xqdh")+"'");
		}	
	}
	
}
